﻿@{
    ViewBag.Title = "Index";
}

<h2>Grants</h2>
@Html.ActionLink("New Grant", "Manage", "Grant", new { }, new { @class = "btn btn-primary" })

<table class="table table-striped hide table-condensed" data-bind="css:{hide:!grants().length}">
    <thead>
        <tr>
            <th>Code</th>
            <th>Name</th>
            <th>Description</th>
            <th>Max duration</th>
            <th>Last updated</th>
            <th></th>

        </tr>
    </thead>
    <tbody data-bind="foreach:grants">
        <tr>

            <td data-bind="text: code"></td>
            <td data-bind="text: name"></td>
            <td data-bind="text: description"></td>
            <td data-bind="text: maxDuration"></td>
            <td data-bind="text: moment(lastUpdated()).fromNow()"></td>
            <td>
                <div class="btn-group ">
                    <a class="btn btn-sm btn-default  dropdown-toggle" data-toggle="dropdown" href="#">
                        <span class=" glyphicon glyphicon-cog"></span>
                        <span class="caret"></span>
                    </a>
                    <ul class="dropdown-menu pull-right">
                        <li>
                            @{ var url = @Url.Action("Manage"); }


                            <a href="#" data-bind="attr: { href: '@url#' + $data.id() }" rel="nofollow">
                                <span class="glyphicon glyphicon-briefcase"></span>
                                Edit
                            </a>
                        </li>
                        <li class="divider"></li>

                        <li>
                            <a href="#" data-confirm="WARNING: This will also delete This cannot be undone. Are you sure you want to delete" data-disable-with="Deleting..." data-bind="click: function (data, evt) { $parent.deleteGrant(data) }" rel="nofollow">
                                <span class="glyphicon glyphicon-trash"></span>
                                Delete
                            </a>
                        </li>

                    </ul>
                </div>
            </td>

        </tr>
    </tbody>
</table>
<p data-bind="css:{hide:grants().length}" class="hide alert alert-warning">
    No Applications Found
</p>


@section scripts{
    <script src="~/Areas/Admin/Scripts/grants.js"></script>
}
